<extend name="Public:base" />
<block name="main">
<div class="col-lg-12">
	<div class="widget-container fluid-height clearfix">
		<div class="heading">
			<h3>表单设计</h3>
		</div>
		<div class="widget-content padded ">
			<table class="table table-bordered table-condensed">
				<tr>
					<td>表名</td>
					<td ><select name="selecttb" >
						<volist name="tables" id="tb">
						<option value="{$tb.TABLE_NAME}">{$tb.TABLE_NAME}</option>
						</volist>
					</select></td>
					<td>模型名</td>
					<td>{$tb.TABLE_NAME}</td>
					<td>中文名称</td>
					<td><a href="#" editable-input data-pk="0" data-name="mdNmae" data-type="text" >{$mdinfo.mdNmae}</a></td>
					<td>表单布局</td>
					<td><a href="#" data-pk="0" editable-select-layout data-name="layout" data-value="{$mdinfo.layout}" data-type="select" ></a></td>
					<td>路径</td>
					<td>{$tb.TABLE_NAME}</td>
					<td>模板名称</td>
					<td><a href="#" editable-tpl data-name="mdNmae" data-type="text" >{$tb_info.tpl}</a></td>
				</tr>
			</table>
		</div>
	</div>
</div>

<div class="col-lg-12">
	<div class="widget-container fluid-height clearfix">
		
		<div class="widget-content padded">
			<table class="table">
				<thead>
					<th width="48">排序</th>
					<th width="50">显示</th>
					<th>字段名称</th>
					<th>标签</th>
					<th>字段类型</th>
					<th>数据类型</th>
					<th>输入提示</th>
					<th>验证</th>
					<th>默认值</th>
				</thead>
				<tbody>
					<volist name="tb_fields" id="f">
					<tr>
						<td>{$f.pos}</td>
						<td><a href="#" editable-select-isshow data-name="isshow" data-type="select" data-value="{$f.isshow}" data-pk="{$f.pos}" ></a></td>
						<td>{$f.fname}</td>
						<td><a href="#" editable-input data-name="label" data-type="text" data-pk="{$f.pos}" >{$f.label}</a></td>
						<td>
						<a href="#" editable-select-type data-name="type" data-type="select" data-value="{$f.type}" data-pk="{$f.pos}" >{$f.type}</a></td>
						<td>{$f.dtype}</td>
						<td><a href="#" editable-input data-name="tips" data-type="text" data-pk="{$f.pos}" >{$f.tips}</a></td>
						<td><a href="#" editable-select-valid data-name="valid" data-type="select" data-value="{$f.valid}" data-pk="{$f.pos}" >{$f.valid}</a></td>
						<td><a href="#" editable-input data-name="def" data-type="text" data-pk="{$f.pos}" >{$f.def}</a></td>
					</tr>
					</volist>
				</tbody>
			</table>			
		</div>
	</div>
</div>



<load href="__PUBLIC__/tphelper/editable/css/bootstrap-editable.css"  />
<load href="__PUBLIC__/tphelper/editable/js/bootstrap-editable.min.js"  />
<script type="text/javascript">
$(document).ready(function() {
	$.fn.editable.defaults.url = '{:U("Mod/updateField?tb=$tb_name&tpl=$tb_info[tpl]")}'; 
	
	$('[editable-tpl]').editable({
		url: '{:U("Mod/updateField")}',
		success: function(response, nv) {
			var url = "{:U("Mod/detail?md=$md&tb=$tb_name")}&tpl="+nv;
    		window.location.href = url;
		}
	});


    $('[editable-input]').editable();
    $('[editable-select-type]').editable({
        prepend: "请选择",
        source: [
            {value: 'input', text: 'input'},
            {value: 'select', text: 'select'},
            {value: 'hidden', text: 'hidden'},
            {value: 'checkbox', text: 'checkbox'},
            {value: 'textarea', text: 'textarea'},
            {value: 'file', text: 'file'},
        ]   
    });

    $('[editable-select-isshow]').editable({
        prepend: "请选择",
        source: [
            {value: '1', text: '显示'},
            {value: '0', text: '隐藏'},
        ]   
    });

    $('[editable-select-valid]').editable({
        prepend: "请选择",
        source: [
            {value: 'required', text: '必填'},
            {value: 'email', text: '邮箱可填'},
        ]   
    });
    $('[editable-select-layout]').editable({
        prepend: "请选择",
        source: [
            {value: 'form-normal', text: '普通'},
            {value: 'form-horizontal', text: '水平'},
            {value: 'form-table', text: '表格'},
            {value: 'form-inline', text: '内联'},
        ]   
    });

    $('select[name=selecttb]').val('{$tb_name}');
    $('select[name=selecttb]').on('change',function(){
    	var tb = $(this).val();
    	if (tb == '{$tb_name}') return;
    	var url = "{:U("Mod/detail?md=$md&tb=")}"+tb;
    	window.location.href = url;
    })


});	
</script>
</block>
